package com.cjst.service.impl.part;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cjst.pojo.part.PartType;
import com.cjst.pojo.sys.SysMenu;
import com.cjst.sdp.util.ZTreeNode;
import com.cjst.service.impl.base.BaseServiceImpl;
import com.cjst.service.part.PartTypeService;
import com.cjst.sql.C;
import com.cjst.sql.Method;
import com.cjst.sql.WherePrams;
import com.cjst.util.CloneClass;

@Service
public class PartTypeServiceImpl extends  BaseServiceImpl<PartType, String> implements PartTypeService {
	@Override
	public List<ZTreeNode> tree(){
		WherePrams wherePrams=Method.where("delFlag", C.EQ, "0");
		List<PartType> partTypes=this.list(wherePrams);
		List<ZTreeNode> nodeList=new ArrayList<ZTreeNode>();
		if(partTypes!=null && partTypes.size()>0){
			for (PartType partType : partTypes) {
				ZTreeNode node=new ZTreeNode();
				CloneClass.getClone(partType, node);
				node.setId(partType.getId());
				node.setpId(partType.getPtypeParent());
				node.setName(partType.getPtypeName());
				nodeList.add(node);
			}
		}
		return nodeList;
	}
}
